import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { EliteTowerPanel } from "./EliteTowerPanel";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { EliteTiaoZhanSp } from "./EliteTiaoZhanSp";
import { EliteEnterFloorSp } from "./EliteEnterFloorSp";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { DataEvent } from "../../../events/DataEvent";
import { EliteTowerFloorData } from "./EliteTowerFloorData";
import { EliteFloorDetailPanel } from "./EliteFloorDetailPanel";
import { EliteDetailPanel } from "./EliteDetailPanel";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { EventName } from "../../../mvc/EventName";
type int = number;
//class GuildEliteModule
    
    export  class GuildEliteModule extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(700, 500);
            this.titleHeight = 25;
            this.title = Language.getString(60601);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._eliteTowerPanel = new EliteTowerPanel();
            this._eliteTowerPanel.x = 20;
            this._eliteTowerPanel.y = 37;
            this._eliteTowerPanel.addEventListener(GModuleEvent.GuildElite_FloorSelectedChange, this.onFloorSelectedChangeHandler);
            this.addChild(this._eliteTowerPanel);
            this._tiaoZhanSp = new EliteTiaoZhanSp();
            this._tiaoZhanSp.x = 0;
            this._enterFloorSp = new EliteEnterFloorSp();
            this._enterFloorSp.x = 0;
            this._enterFloorSp.y = 345;
            this._enterFloorSp.addEventListener(GModuleEvent.GuildElite_FloorSelectedChange, this.onEnterSpFloorSelectedChangeHandler);
            this.updateFloorInfo();
            LoaderHelp.addResCallBack(ResFileConst.guildElite, this.onLoaded);
            return;
        }

        /* internal  */onLoaded(): void
        {
            if (this._eliteTowerPanel) 
            {
                this._eliteTowerPanel.onResLoaded();
            }
            if (this._tiaoZhanSp) 
            {
                this._tiaoZhanSp.onResLoaded();
            }
            if (this._mainDetail) 
            {
                this._mainDetail.onResLoaded();
            }
            if (this._floorDetail) 
            {
                this._floorDetail.onResLoaded();
            }
            return;
        }

        /* internal  */onFloorSelectedChangeHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as EliteTowerFloorData;
            this._enterFloorSp.selectedFloor = this._eliteTowerPanel.selectedFloor;
            this.updateFloorInfo();
            return;
        }

        /* internal  */onEnterSpFloorSelectedChangeHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as EliteTowerFloorData;
            this._eliteTowerPanel.selectedFloor = loc1.floor;
            this.updateFloorInfo();
            return;
        }

        public setSelectedFloor(arg1: int): void
        {
            this._eliteTowerPanel.selectedFloor = arg1;
            this._enterFloorSp.selectedFloor = arg1;
            this.updateFloorInfo();
            return;
        }

        public getSelectedFloor(): int
        {
            return this._eliteTowerPanel.selectedFloor;
        }

        public updateEnterSpDp(): void
        {
            this._enterFloorSp.updateDataProvider();
            return;
        }

        public glowEffect(): void
        {
            this._eliteTowerPanel.glowEffect();
            return;
        }

        /* internal  */updateFloorInfo(): void
        {
            var loc1=this._eliteTowerPanel.selectedFloor;
            if (loc1 != 0) 
            {
                if (this._mainDetail && this._mainDetail.parent) 
                {
                    this._mainDetail.parent.removeChild(this._mainDetail);
                }
                if (!this._floorDetail) 
                {
                    this._floorDetail = new EliteFloorDetailPanel();
                    this._floorDetail.x = 397;
                    this._floorDetail.y = 37;
                }
                this.addChild(this._floorDetail);
                this._tiaoZhanSp.y = 5;
                this._floorDetail.addChild(this._tiaoZhanSp);
                this._floorDetail.addChild(this._enterFloorSp);
                this._floorDetail.updateMapsStatus(this._eliteTowerPanel.selectedFloorData.maps);
            }
            else 
            {
                if (this._floorDetail && this._floorDetail.parent) 
                {
                    this._floorDetail.parent.removeChild(this._floorDetail);
                }
                if (!this._mainDetail) 
                {
                    this._mainDetail = new EliteDetailPanel();
                    this._mainDetail.x = 397;
                    this._mainDetail.y = 37;
                }
                this.addChild(this._mainDetail);
                this._tiaoZhanSp.y = 160;
                this._mainDetail.addChild(this._tiaoZhanSp);
                this._mainDetail.addChild(this._enterFloorSp);
            }
            var loc2=this._eliteTowerPanel.selectedFloorData;
            this._tiaoZhanSp.updateData(loc2);
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildElite_GetFloorPlayerNum, loc2));
            return;
        }

        public updateLeftTime(arg1: int): void
        {
            this._tiaoZhanSp.updateLeftTime(arg1);
            return;
        }

        public updatePreLeftTime(arg1: int): void
        {
            this._tiaoZhanSp.updatePreLeftTime(arg1);
            return;
        }

        public updatePlayerNum(arg1: int, arg2: int): void
        {
            this._tiaoZhanSp.updatePlayerNum(arg1, arg2);
            return;
        }

        /* internal */ /* var */_eliteTowerPanel: EliteTowerPanel;

        /* internal */ /* var */_mainDetail: EliteDetailPanel;

        /* internal */ /* var */_floorDetail: EliteFloorDetailPanel;

        /* internal */ /* var */_tiaoZhanSp: EliteTiaoZhanSp;

        /* internal */ /* var */_enterFloorSp: EliteEnterFloorSp;
    }
